<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var date = new Date();
        console.log(date.getHours());
        //要求封装一个函数，返回当前的时分秒
        function getTime() {
            var Time = new Date();
            var hours = Time.getHours();
            hours = hours < 10 ? "0" + hours : hours;
            var mintues = Time.getMinutes();
            mintues = mintues < 10 ? "0" + mintues : mintues;
            var seconeds = date.getSeconds();
            seconeds = seconeds < 10 ? "0" + seconeds : seconeds;
            return hours + ":" + mintues + ":" + seconeds;
        }
        console.log(getTime());
    </script>
</head>

<body>

</body>

</html>